package entity;

import java.util.HashMap;

public class Relation {

    private Long id;
    public Node nodeFrom = null;
    public Node nodeTo = null;
    public RelationshipType relationshipType = RelationshipType.UNKNOWN;

    public Relation(Long id, Node nodeFrom, Node nodeTo, RelationshipType relationshipType) {
        this.id = id;
        this.nodeFrom = nodeFrom;
        this.nodeTo = nodeTo;
        this.relationshipType = relationshipType;
    }

    public Relation(Node nodeFrom, Node nodeTo, RelationshipType relationshipType) {
        this.id = -1L;
        this.nodeFrom = nodeFrom;
        this.nodeTo = nodeTo;
        this.relationshipType = relationshipType;
    }

    public Relation() {
    }

    public static HashMap<String, RelationshipType> relationTypeMap = new HashMap<String, RelationshipType>() {{
        put("INCL", RelationshipType.INCL);
        put("SEQ", RelationshipType.SEQ);
        put("ASSC", RelationshipType.ASSC);
    }};

    public Node getNodeFrom() {
        return nodeFrom;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public void setNodeFrom(Node nodeFrom) {
        this.nodeFrom = nodeFrom;
    }

    public Node getNodeTo() {
        return nodeTo;
    }

    public void setNodeTo(Node nodeTo) {
        this.nodeTo = nodeTo;
    }

    public RelationshipType getRelationshipType() {
        return relationshipType;
    }

    public void setRelationshipType(RelationshipType relationshipType) {
        this.relationshipType = relationshipType;
    }

    @Override
    public String toString() {
        return "Relation{" +
                "id=" + id +
                ", nodeFrom=" + nodeFrom +
                ", nodeTo=" + nodeTo +
                ", relationshipType=" + relationshipType +
                '}';
    }
}
